/**** SpringProxAPI/sprox_api.c
 *
 * NAME
 *   SpringProxAPI :: Entry points
 *
 * DESCRIPTION
 *   Major entry points of the DLL
 *
 * HISTORY
 *
 *  JDA 23/06/2004 : created
 *  JDA 02/12/2005 : changed "#ifdef SPROX_MULTI_INSTANCE" to "#ifdef SPROX_API_REENTRANT"
 *
 **/

#include "sprox_api_i.h"

DWORD DefaultForceBaudrate = 0;

#ifndef SPROX_API_REENTRANT
static SPROX_CTX_ST  sprox_ctx_def;
SPROX_CTX_ST        *sprox_ctx_glob = &sprox_ctx_def;
#endif


#ifdef SPROX_API_REENTRANT

SPRINGPROX_LIB SPROX_INSTANCE SPRINGPROX_API SPROXx_CreateInstance(void)
{ 
  return calloc(1, sizeof(struct _SPROX_CTX_ST));
}

SPRINGPROX_LIB void SPRINGPROX_API SPROXx_DestroyInstance(SPROX_INSTANCE instance)
{
  SPROXx_ReaderClose(instance);
}

#else

SPRINGPROX_LIB void SPRINGPROX_API SPROX_SelectInstance(SPROX_INSTANCE rInst)
{
  sprox_ctx_glob = (SPROX_CTX_ST *) rInst;
  if (sprox_ctx_glob == NULL)
    sprox_ctx_glob = &sprox_ctx_def;
}

#endif


